“The instruction at ‘ox7c911639’ referenced memory at ‘ox001bd355’ the memory could not be read”
Hi , I am using Visual studion 2003 and i have deployed my utility on XP . That utility is running after every one minute .I am facing following problems in that utility. 1) When that utility run CPU processing reach to 100%( only for 3 to 4 seconds )2) Once a day i will get that error message. “The instruction at ‘ox7c911639’ referenced memory at ‘ox001bd355’ the memory could not be read” following is the code i am using static void Main(string[] args) { // // TODO: Add code to start application here // try { //string ch \Desktop\Images"; string ch = FilePath; string fileName=""; DirectoryInfo dir = new DirectoryInfo(ch); FileInfo[] bmpfiles = dir.GetFiles("*.bmp"); LogTrace("Total number of bmp files " + bmpfiles.Length); DateTime dt = new DateTime(1900,1,1); StreamReader sr1 = new StreamReader(@"Log1.txt"); string oldFileName =sr1.ReadLine(); sr1.Close(); foreach( FileInfo f in bmpfiles) if(f.CreationTime>dt) { dt = f.CreationTime; fileName=f.FullName ; } if (oldFileName!=fileName) { StreamWriter sr2 = new StreamWriter (@"Log1.txt"); sr2.Write(fileName); sr2.Close(); byte[] imageData = ReadFile(fileName); //Initialize SQL Server Connection SqlConnection CN = new SqlConnection(connectionString); //Set insert query string qry = "Delete from ImagesStore where Station=@station; insert into ImagesStore values( @OriginalPath,@ImageData,@Station)"; //Initialize SqlCommand object for insert. // sr2.Write(qry); SqlCommand SqlCom = new SqlCommand(qry, CN); //We are passing Original Image Path and //Image byte data as sql parameters. SqlCom.Parameters.Add(new SqlParameter("@OriginalPath",(object)fileName)); SqlCom.Parameters.Add(new SqlParameter("@ImageData", (object)imageData)); SqlCom.Parameters.Add(new SqlParameter("@station", (object)Station)); //Open connection and execute insert query. CN.Open(); SqlCom.ExecuteNonQuery(); CN.Close(); imageData=null; CN=null; imageData=null; dir=null; connectionString=null; FilePath=null; Station=null; bmpfiles=null; dir=null; GC.Collect(); GC.WaitForPendingFinalizers(); } } catch(Exception ex) { LogTrace("Exception" + ex.Message); } } public static byte[] ReadFile(string sPath) { byte[] data = null; try { //Initialize byte array with a null value initially. //Use FileInfo object to get file size. FileInfo fInfo = new FileInfo(sPath); long numBytes = fInfo.Length; //Open FileStream to read file FileStream fStream = new FileStream(sPath, FileMode.Open,FileAccess.Read); //Use BinaryReader to read file stream into byte array. BinaryReader br = new BinaryReader(fStream); //When you use BinaryReader, you need to //supply number of bytes to read from file. //In this case we want to read entire file. //So supplying total number of bytes. data = br.ReadBytes((int)numBytes); fStream.Close(); br.Close(); } catch(Exception ex) { LogTrace("Exception" + ex.Message); } return data; } private static void LogTrace(string message) { StreamWriter streamWriter = null; try { FileInfo file = new FileInfo("Log.txt"); if(file.Length >= 1048576) file.Delete(); streamWriter = File.AppendText("Log.txt"); streamWriter.WriteLine(System.DateTime.Now.ToString() + " : " + message); } catch(Exception) { } finally { if(streamWriter != null) streamWriter.Close(); } } If you have any queries please let me know. regards,Talha1 person needs an answerI do too
June 15th, 2010 9:17am

You might want to check in an MSDN forum: http://social.msdn.microsoft.com/Forums/en-us/categories/
Free Windows Admin Tool Kit Click here and download it now
June 15th, 2010 1:32pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics